<template>
  <div>
    <section class="productsAndServices">
      <p class="productCategory">产品类目</p>
      <div class="flex">
        <div class="left">
          <el-tabs tab-position="left" style="height: 200px" @tab-change="selectType">
            <el-tab-pane
              :label="item.serverType"
              v-for="(item, index) in categoryList"
              :key="index"
            />
          </el-tabs>
        </div>
        <unicomAdvancedDefense class="right" :title="serverType" :serverTypeId="serverTypeId" />
      </div>
    </section>
  </div>
</template>
<script lang="ts" setup>
import { onMounted, ref } from "vue";
import unicomAdvancedDefense from "./unicomAdvancedDefense.vue";
import { typeList } from "@/api/zhengWuYun";

const categoryList = ref<any>([]);
const serverType = ref(""); // 选中产品类目
const serverTypeId = ref(""); // 选中产品类目id

onMounted(() => {
  getTypeList();
});

// 获取产品类目
const getTypeList = () => {
  let data = {
    params: {
      pageNum: 1,
      pageSize: 100000,
    },
  };
  typeList(data).then((res: any) => {
    categoryList.value = res.rows;
    if (categoryList.value.length > 0) {
      serverType.value = categoryList.value[0].serverType;
      serverTypeId.value = categoryList.value[0].serverTypeId;
    }
  });
};

// 获取类目下的产品列表
const selectType = (tab: any) => {
  serverType.value = categoryList.value[tab].serverType;
  serverTypeId.value = categoryList.value[tab].serverTypeId;
};
</script>
<style lang="less" scoped>
/deep/.el-tabs--left {
  height: auto !important;
}
/deep/.el-tabs--left .el-tabs__item.is-left {
  justify-content: left;
  height: 60px;
}
/deep/.el-tabs--left .el-tabs__active-bar.is-left {
  left: 0;
  height: 60px;
}
/deep/.el-tabs--left .el-tabs__nav-wrap.is-left::after {
  left: 0;
}
/deep/.el-tabs--left .el-tabs__header.is-left {
  padding-top: 40px;
}
/deep/.el-tabs__content {
  padding-top: 4px;
}
.productsAndServices {
  position: relative;
  .productCategory {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 30px;
    position: absolute;
  }
}
.flex {
  display: flex;
  justify-content: space-between;
  .left {
    width: 210px;
  }
  .right {
    flex: 1;
  }
}
</style>
